package cn.tedu.controller;

import cn.tedu.common.JsonResult;
import cn.tedu.pojo.param.OrderAddParam;
import cn.tedu.service.OrderService;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/order")
@RestController
@Api(tags = "订单接口")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @ApiOperation("创建订单")
    @PostMapping ("create")


    public JsonResult createOrder(@RequestBody OrderAddParam orderAddParam){
        String orderNo = orderService.createOrder(orderAddParam);
        JsonResult< String> jsonResult = new JsonResult<>();
        jsonResult.setCode("2000");
        jsonResult.setData(orderNo);
        jsonResult.setMessage("创建订单成功");
        return jsonResult;


    }

}
